import { prisma } from '@/utils/backend/db'
import { HttpStatus } from '@/utils/httpStatus'
import { NextResponse } from 'next/server'

export const GET = async () => {
  try {
    const users = await prisma.user.findMany({
      orderBy: {
        createdAt: 'desc'
      }
    })

    return NextResponse.json({
      success: true,
      message: '获取导出数据成功',
      data: users
    })
  } catch (error) {
    return NextResponse.json(
      {
        success: false,
        message: '获取导出数据失败'
      },
      { status: HttpStatus.INTERNAL_SERVER_ERROR }
    )
  }
}
